home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 1429 / sysclk.cpp < prev    next >
C/C++ Source or Header  |  1995-08-27  |  2KB  |  103 lines

  1. //    ************************************************************
  2. //
  3. //    System-Click 'System Control at a Mouseclick'
  4. //    Win95 32-bit Shell Extension
  5. //        James P. Ketrenos
  6. //
  7. //    ************************************************************
  8. #include <afxwin.h>
  9.  
  10. #include "Resource.h"
  11. #include "Global.h"
  12. #include "SysClk.h"
  13. #include "IconWnd.h"
  14.  
  15.  
  16. //    ************************************************************
  17. //    CSysClkApp Class Implementation
  18. //
  19. //    Purpose:
  20. //    *    Main application initialization
  21. //    *    Check for prior instances
  22. //    *    Create main application window
  23. //
  24. //    ************************************************************
  25.  
  26.  
  27.  
  28. //    *******************************
  29. //    CSysClkApp::InitInstance()
  30. //
  31. //    Purpose:
  32. //    *    Checks to see if the 'FullDragApp' mutex already exists.  If
  33. //        not, then it claims it.
  34. //    *    Creates the main application window and hides it.
  35. //    *******************************
  36. BOOL    CSysClkApp::InitInstance()
  37. {    
  38. CIconWnd*        pWnd;
  39. CString            FileName;
  40. CRect            Rect;
  41.  
  42.     //    Check for Mutex and claim it if not there
  43.     m_Mutex    = CreateMutex(NULL, TRUE, "SysClkApp");
  44.     if (GetLastError() == ERROR_ALREADY_EXISTS)
  45.     {
  46.         MessageBox(
  47.             NULL, 
  48.             "System-Click already running.",
  49.             "System-Click",
  50.             MB_ICONSTOP);
  51.  
  52.         return    FALSE;
  53.     }
  54.         
  55.     //    Create our applications window
  56.     pWnd        = new CIconWnd;
  57.     m_pMainWnd    = (CWnd*)pWnd; 
  58.     
  59.     ::GetWindowRect(GetDesktopWindow(), Rect);
  60.  
  61.     if (pWnd->Create(NULL, "System-Click", WS_OVERLAPPEDWINDOW, Rect) == 0)
  62.     {
  63.         MessageBox(NULL, "Failed to create main window", "System-Click", MB_ICONSTOP);
  64.         return    FALSE;
  65.     }
  66.  
  67.     pWnd->ShowWindow(SW_HIDE);
  68.     
  69.     //    Initialize the Notification Icon.
  70.     //    NOTE:    The icon will only appear if the NotifyIcon entry
  71.     //            in our INI file is set to 1 (TRUE).
  72.     if (pWnd->m_InitIcon() == FALSE)
  73.     {
  74.         MessageBox(NULL, "Failed to create notification icon.", "System-Click", MB_ICONSTOP);
  75.         return    FALSE;
  76.     }
  77.  
  78.     return    TRUE;
  79. }
  80.  
  81.  
  82.  
  83. //    *******************************
  84. //    CSysClkApp::ExitInstance()
  85. //
  86. //    Purpose:
  87. //    *    Destroys the mutex that let's other instances know we are 
  88. //        already running.
  89. //    *******************************
  90. int        CSysClkApp::ExitInstance()
  91. {
  92.     ReleaseMutex(m_Mutex);
  93.     
  94.     return CWinApp::ExitInstance();
  95. }
  96.  
  97.  
  98.  
  99. //    *******************************
  100. //    Create our window
  101. //    *******************************
  102. CSysClkApp    FullDrag;
  103.